#include <iostream>
#include <cstdlib>
#include <cctype>

void readAndClean(int &n);
// 读取一行输入，丢弃除了数字之外的所有符号
// 将C字符串转换成整数，将n设置成该整数的值

int main()
{
    using namespace std;
    int n;
    char ans;
    cout << "Please input the string";
    readAndClean(n);
    cout << "This string converts to the integer" << n << endl;
    return 0;
}

void readAndClean(int &n)
{
    using namespace std;
    const int array_size = 6;
    char digitString[array_size];
    char next;
    cin.get(next);
    int index = 0;
    while (next != '\n')
    {
        if ((isdigit(next)) && (index < array_size - 1))
        {
            digitString[index] = next;
            index++;
        }
        cin.get(next);
    }
    digitString[index] = '\0';
    n = atoi(digitString);
}